package com.songlanyun.modules.shop.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.modules.shop.entity.ShopAdminRelationEntity;
import com.songlanyun.modules.shop.entity.ShopEntity;
import com.songlanyun.modules.shop.model.dto.ShopApplyDTO;
import com.songlanyun.modules.shop.model.dto.ShopRateDTO;
import com.songlanyun.modules.shop.model.vo.ShopInfoVO;
import com.songlanyun.modules.shop.model.vo.ShopVO;
import com.songlanyun.modules.shop.model.vo.ShopWithdrawVO;
import com.songlanyun.modules.user.entity.SysUserEntity;
import com.songlanyun.modules.user.entity.SysUserEntityDTO;


import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 商家表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-11-03 14:34:03
 */
public interface ShopService extends IService<ShopEntity> {

    PageUtils queryPage(Map<String, Object> params);

    /**
     * 平台店铺
     *
     * @return
     */
    ShopEntity selectPlatformShop();

    /**
     * 平台店铺id
     *
     * @return
     */
    Long selectPlatformShopId(boolean tw);

    ShopEntity loadShopBy(Long shopId, Boolean tw);

    void initializeShop(ShopApplyDTO dto);

    void updateShop(ShopEntity shopEntity);

    void assignedAccount(ShopEntity shop, SysUserEntityDTO user);

    /**
     * 根据会员id查询商铺
     *
     * @param userId
     * @return
     */
    ShopEntity getShopByUserId(Long userId, boolean unionBusiness);

    /**
     * 根据会员id查询商铺id
     *
     * @param userId
     * @return
     */
    Long getShopIdByUserId(Long userId, boolean unionBusiness);

    ShopEntity getSubShopById(Long userId, boolean unionBusiness);

    void saveShopAdmin(SysUserEntity user, Long shopId, boolean isShop);

    /**
     * //根据管理员账号id查询自己的会员id
     *
     * @param userId
     * @return
     */
    Long getUserIdByAdminId(Long userId, boolean unionBusiness);

    void deleteShop(List<Long> longs);

    List<ShopEntity> nearbyShop(Map<String, Object> params);

    ShopEntity getById(Long shopId, boolean isThrow);

    ShopEntity loadByIdForLock(Long shopId, boolean isThrow);

    BigDecimal getGainsAble(Long shopId);

    /**
     * 更新商家收益
     *
     * @param shopId
     * @param money
     * @return
     */
    ShopEntity updateShopGains(Long shopId, BigDecimal money);

    void resetShopPassword(Long shopId);

    void updateAverageById(Long shopId, BigDecimal average);

    /**
     * 获取提现相关金额（可提现所得,已提现所得,锁定金额）
     *
     * @param shopId
     * @return
     */
    ShopWithdrawVO getWithdrawAmount(Long shopId);

    /**
     * 根据商家查询管理员主账号
     *
     * @param shopId
     * @return
     */
    SysUserEntity getAdminByShopId(Long shopId);

    void updateByShopAllInfo(ShopApplyDTO dto, ShopEntity shop);

    ShopInfoVO getShopInfo(Long shopId);

    /**
     * 根据管理员id查询商家
     *
     * @return
     */
    ShopEntity getShopByAdminId(Long adminId, boolean unionBusiness);

    Long getAdminPriByShopId(Long id);

    /**
     * 根据商家id获取会员邀请码
     *
     * @param shopId
     * @return
     */
    String getCodeByShopId(Long shopId);

    /**
     * 判断是否是商家
     *
     * @param userId
     * @return
     */
    Boolean isShopByAccountId(Long userId, boolean unionBusiness);

    List<ShopEntity> allShopCity(String city, boolean unionBusiness);

    List<ShopEntity> allShop(boolean unionBusiness);

    void setCommissionRate(ShopRateDTO dto);

    Integer getShopNum(String areaCode, boolean unionBusiness);

    void show(Long shopId);
    void mathCalculate(String lon, String lat, ShopEntity shop);

    /**
     * 获取Api端会员的商家信息
     *
     * @param userId        会员ID
     * @param unionBusiness 是否是联盟商家
     * @return
     */
    ShopEntity getApiShopInfo(Long userId, boolean unionBusiness);
}

